<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib prefix="s" uri="/struts-tags"%>
<s:set name="vendors" value="#order.vendors" />
<script type="text/javascript">
<!--
function showQuoteDetail(btn,id){
	var detail = $("#"+id);
	if(detail.is(':visible')){
	detail.hide();
		$(btn).val("明细");
	}
	else{ detail.show();
		$(btn).val("隐藏");
	}
}
//-->
</script>
<s:iterator value="#order.vendors" id="vendor" status="vstatus">
	<s:set name="quoteMap" value="#vendor.quoteMap" />
	<s:set name="isVotedVendor" value="#orderCustomer.isVotedVendor(#vendor)" />
	<div class="box_blue" id="company_<s:property value="#vstatus.index"/>">
		<div class="box_title">
			<a href="<%=request.getContextPath()%>/company/viewVendorInfo.do?id=<s:property value="#vendor.company.id"/>" target="_blank"> <s:property value="#vendor.company.name" /> </a>
			<input type="button" value="明细" onclick="javascript:showQuoteDetail(this,'quotedetail_<s:property value="#vstatus.index"/>');" />
		</div>
		<div class="vendorList <s:if test="#isVotedVendor">voted</s:if> ">
			<div id="quotedetail_<s:property value="#vstatus.index"/>" class="hidden">
				<table style="width: 100%;">
					<tr>
						<th width="20">
							NO.
						</th>
						<th>
							商品/服务名称
						</th>
						<th width="200">
							要求
						</th>
						<th width="50" align="right">
							单位数量
						</th>
						<th width="150" align="right">
							商品/服务单价
						</th>
						<th width="150" align="right">
							运费/杂费
						</th>
					</tr>
					<s:set name="totalAmount" value="0" />
					<s:set name="totalCarriage" value="0" />

					<s:iterator value="#orderCustomer.orderRequests" id="request" status="status">
						<s:set name="quote" value="#quoteMap.get(#request)" />
						<tr>
							<td>
								<s:property value="#status.index+1" />
							</td>
							<td>
								<s:property value="#request.product.name" />
							</td>
							<td>
								<s:property value="toHtml(#request.comment)" escape="false" />
							</td>
							<td align="right">
								<s:property value="#request.count" />
							</td>
							<td align="right">
								<s:property value="#quote.amount" />
							</td>
							<td align="right">
								<s:property value="#quote.carriage" />
							</td>
						</tr>
						<s:set name="totalAmount" value="#totalAmount+ #quote.amount*#request.count" />
						<s:set name="totalCarriage" value="#totalCarriage+ #quote.carriage" />
					</s:iterator>
					<s:if test="#totalAmount!=null && #totalCarriage!=null">
						<tr>
							<td colspan="4">

							</td>
							<td width="150" align="right">
								<s:property value="#totalAmount" />
							</td>
							<td width="150" align="right">
								<s:property value="#totalCarriage" />
							</td>
						</tr>
					</s:if>
				</table>
				<s:if test="#vendor.declaration!=null">
					<div class="declaration">
						<s:property value="toHtml(#vendor.declaration)" escape="false" />
					</div>
				</s:if>
			</div>
			<s:if test="#totalAmount==null || #totalCarriage==null">
				<div style="text-align: right; font-size: 16px; font-weight: bold; color: red;">
					此供应商还没有完成报价!
				</div>
			</s:if>
			<s:else>
				<div>
					<font style="font-size: 16px; font-weight: bold; color: red;">总计: <s:property value="#totalAmount + #totalCarriage" /> </font>
					<s:if test="!#isVotedVendor">
					为此供应商<input type="button" class="btn_yellow_2" onclick="javascript:jtool.goto('<%=request.getContextPath()%>/order/voteOrder.do?orderId=<s:property value="#order.Id"/>&customerId=<s:property value="#orderCustomer.id"/>&vendorId=<s:property value="#vendor.id"/>');" value="投票" />
					</s:if>
					<s:else>
						<font color="red">你已经为此供应商投票！</font>
					</s:else>
				</div>
			</s:else>
		</div>
	</div>
</s:iterator>
